Use mod_proxy #2
2016/02/03 |
Enable mod_proxy module to configure reverse proxy settings. This example is based on the environment below.
This example set servers that requests to (1)Web server forward to / on (2)webserver.
|
|||||||
[1] | mod_proxy is included in apache2 package by default, so it's possible to configure quickly. |
root@www:~# a2enmod proxy proxy_http
root@www:~#
vi /etc/apache2/mods-enabled/proxy.conf # add into <IfModule mod_proxy **> - </IfModule>
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://node01.srv.world/
ProxyPassReverse / http://node01.srv.world/
root@www:~# /etc/init.d/apache2 restart * Restarting web server apache2 ...done. |
Access to frontend server to make sure backend server responses like follows. |
[2] |
It's possible to configure load balancing settings.
|
root@www:~# a2enmod proxy proxy_http lbmethod_byrequests
root@www:~#
vi /etc/apache2/mods-enabled/proxy.conf # add into <IfModule mod_proxy **> - </IfModule>
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
# specify the way of load balancing with "lbmethod". it's also possible to set "bytraffic".
ProxyPass / balancer://cluster lbmethod=byrequests
<proxy balancer://cluster>
BalancerMember http://node01.srv.world/ loadfactor=1
BalancerMember http://node02.srv.world/ loadfactor=1
</proxy>
root@www:~# /etc/init.d/apache2 restart * Restarting web server apache2 ...done. |
Access to frontend server to make sure backend servers responses like follows. |